package clientserver;

import java.net.*;
import java.io.*;




public class ChatServerThread extends Thread  {
	
	public Socket			socket = null;
	ChatServer		Server = new ChatServer();
	private int				ID	=	-1;
	private DataInputStream streamIn = null;
	private	InetAddress				IP;
	
	public ChatServerThread(ChatServer Server,Socket  socket)
	{
		Server = Server;	
		socket = socket;
		ID = socket.getPort();
		IP = socket.getInetAddress();
	}
	
	public void run()
	{
		System.out.println("Server Thread " +ID + "IP = "+IP+ "running.");
		while(true)
		{try
		{System.out.println(streamIn.readUTF());	
	}
		catch (IOException ieo){ }
	
		}
	}
	
	public void open() throws IOException
	{
		streamIn = new DataInputStream (new BufferedInputStream(socket.getInputStream()));
		
	}
	public void close()	throws IOException
	{
		if (socket != null) socket.close();
		if (streamIn != null) streamIn.close();
	}
	


}
